
package ihm_clarifiee.Presentation.popup;

import ihm_clarifiee.Control.CEquipe;
import ihm_clarifiee.Control.CProjet;
import ihm_clarifiee.Presentation.PProjet;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.JSpinner;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import com.lavantech.gui.comp.DateTimePicker;
import com.sun.xml.internal.bind.v2.runtime.reflect.Lister;
import ihm_clarifiee.Control.CEquipe;
import ihm_clarifiee.Presentation.PListeEquipe;
import ihm_clarifiee.application.Utilisateur;


/**
 *
 * @author Revan
 */
public class popup_equipe extends javax.swing.JPanel implements popup {

    private CProjet projet;
    private CEquipe Equipe;
  


    public popup_equipe(CProjet p) {
        projet =p;
       
        initComponents();
    }
     public popup_equipe(CProjet p, CEquipe eq) {
        projet =p;
        Equipe=eq;
        initComponents();
        tb_nom.setText(eq.getNom());
        ta_description.setText(eq.getScumMaster().getNom()+" "+eq.getScumMaster().getPrenom());
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ta_description = new javax.swing.JTextArea();
        tb_nom = new javax.swing.JTextField();
        tb_scrumMaster_n =  new javax.swing.JTextField();
        tb_scrumMaster_p = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
       

        setMaximumSize(new java.awt.Dimension(350, 350));
        setPreferredSize(new java.awt.Dimension(324, 297));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Nom");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel2.setText("Nom de ScrumMaster");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel3.setText("Prenom de ScrumMaster");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel4.setText("Description");

        ta_description.setColumns(20);
        ta_description.setRows(5);
        jScrollPane1.setViewportView(ta_description);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel5.setText("Equipe");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addContainerGap(345, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                            .addComponent(tb_nom, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                            .addComponent(tb_scrumMaster_n, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                            .addComponent(tb_scrumMaster_p, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                        ).addGap(28, 28, 28))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tb_nom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tb_scrumMaster_n, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               ) .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(tb_scrumMaster_p, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                ).addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );
    }// </editor-fold>


    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea ta_description;
    private javax.swing.JTextField tb_nom;
    private javax.swing.JTextField tb_scrumMaster_n;
    private javax.swing.JTextField tb_scrumMaster_p;


    private javax.swing.JSpinner js;
    
    public boolean valider() {

        if(Equipe==null)
        {
        try{
        	String n =tb_scrumMaster_n.getText();
        	String p=tb_scrumMaster_p.getText();
        	Utilisateur u=new Utilisateur(n,p);
             	
        	projet.creerEquipe(tb_nom.getText(),u ,ta_description.getText());
       
        // projet.getPresentation().updateListeReleases();
        PListeEquipe pu = projet.getPresentation().getListeEquipe();
  
      
        }
        catch(Exception e)
        {
            System.out.println(e);
            return false;

        }
      
    }

    else
    {
        Equipe.setNom(tb_nom.getText());
        Equipe.setDescription(ta_description.getText());
        Equipe.setScrumMaster(new Utilisateur(tb_scrumMaster_n.getText(),tb_scrumMaster_p.getText()));
        
     //   Equipe.setDateDebut(tb_datedebut.getDate());
      //  release.setDateFin(tb_datefin.getDate());
    }

       projet.getPresentation().updateListeEquipe();
      return true;
    // End of variables declaration

}
}
